<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>养护管理--${fns:getConfig('productName')}</title>
<%@ include file="/common/meta.jsp"%>
        <link rel="stylesheet" type="text/css" href="${ctx}/styles/css/default.css">
        <link href="${ctx}/styles/css/fileinput.css" media="all" rel="stylesheet" type="text/css" />
        <script src="${ctxStatic}/jquery/jquery-2.0.2.min.js" type="text/javascript"></script>
        <script src="${ctx}/js/fileinput.js" type="text/javascript"></script>
<!--         简体中文 -->
        <script src="${ctx}/js/zh.js" type="text/javascript"></script>
<!--         繁体中文 -->
        <script src="${ctx}/js/zh-TW.js" type="text/javascript"></script>
		<script src="${ctx}/js/bootstrap.min.js" type="text/javascript"></script>
<%@ include file="/common/jqGridHead.jsp"%>
<script src="${ctxStatic}/js/yh/dailySupervion.js" type="text/javascript"></script>

</head>
<body>
	<ul class="nav nav-tabs" style="margin-bottom: 10px;">
		<c:forEach items="${list}" var="menu"  varStatus="idxStatus">
			<li class="${menu.tag eq tag?'active':''}">
				<a href="${ctx}/${menu.href}">
					<i class="icon icon-list" style="margin-right:10px"></i><span>${menu.name}</span>
				</a>
			</li>
		</c:forEach>
	</ul>
    <tags:message content="${msg}" />
	<form id="mainForm"  role="form" method="get">
		<div class="breadcrumb form-search" style="background-color: #f5f5f5;">
			<div>
				<label>关键字:</label>
				<input type="text" oninput="queryForGrid('mainForm','jqGrid')" onporpertychange="queryForGrid('mainForm','jqGrid')"  name="filter_LIKES_fileName_OR_fileOrg_OR_ownOrg_OR_type_OR_uploadPerson" placeholder="文件查询" />
					<a href="#myModal" id="employee" class="btn btn-primary"role="button" data-toggle="modal">上传附件&nbsp;
						<i class="icon icon-list" style=" margin-top:4px"></i>
					</a>
			</div>
		</div>
	</form>
<%-- 	<jsp:include page="/WEB-INF/views/attachment.jsp"/>  --%>
<form id="fileForm" name="fileForm" method="post" class="form-horizontal"
   action="${ctx}/dailySupervion/save.do?top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}&LId=${fns:encodeParam(LId)}&parentId=${fns:encodeParam(parentId)}&tag=${fns:encodeParam(tag)}"  enctype="multipart/form-data">
   <input type="hidden" name="token" value="${token}">
   <input type="hidden" name="attPath" id="attPath" value="">
   <input type="hidden" name="id" id="id" value="">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" style="width:820px;max-height:700px">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="myModalLabel">新增/修改文件</h4>
					</div>
					<div class="modal-body" style="max-height:670px;">
						<table class="table"  style="border: none;margin-bottom: -14px">
							<tbody>
								<tr>
									<td  id="eremark">选择文件:</td>
									<td colspan="3">
									<input id="file-0a" class="file" name="file" type="file" multiple data-min-file-count="1">    
									</td>
								</tr>
								<tr>
									<td  id="efileOrg">发文单位<font color="red">&nbsp;*</font>:</td>
									<td  class="eminput">
										<input name="fileOrg" id="fileOrg" maxlength="40" type='text' value="" class="required">
									</td>
									<td id="efileNo">文件编号<font color="red">&nbsp;*</font>:</td>
									<td>
										<input name="fileNo" id="fileNo" maxlength="50" type='text' value="" class="required">
									</td>
								</tr>
								<tr>
									<td  id="ereelNumber">卷　　号:</td>
									<td  class="eminput">
										<input name="reelNumber" id="reelNumber" maxlength="40" type='text' value="" >
									</td>
									<td id="enumber">　第X本:</td>
									<td>
										<input name="number" id="number" maxlength="10" type='text' value="">
									</td>
								</tr>
								<tr>
									<td  id="efileTime">发文日期<font color="red">&nbsp;*</font>:</td>
									<td  class="eminput">
										<input  id="fileTime" name="fileTime" value="" class="required"
										onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate" type="text">
									</td>
									<td id="eownOrg">所属单位<font color="red">&nbsp;*</font>:</td>
									<td>
										<input name="ownOrg" id="ownOrg" maxlength="40" type='text' value="" class="required">
									</td>
								</tr>
								<tr>
									<td  id="eremark">备注:</td>
									<td colspan="3">
										<input name="remark" id="remark" maxlength="50" type='text' value="" >
									</td>
								</tr>
								<tr>
									<td  id="eremark">文件描述:</td>
									<td  colspan="3" >
										<div class="wordCount wyInline" id="wordCount">
											<textarea placeholder="文件内容描述" rows='3' id="fileDesc"
												name="fileDesc"></textarea>
											<span class="wordwrap"><var class="word">512</var>/512</span>
										</div>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="modal-footer" style="padding:4px 15px 5px;">
						<button type="button" class="btn btn-default" data-dismiss="close">关闭</button>
						<button type="button" class="btn btn-danger" onclick="delDaily();" style="display:none;" id="delDailySuperv">删除</button>
						<button type="submit" class="btn btn-primary" >提交</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal -->
		</div>
</form>
	<table id="jqGrid"></table>
	<div id="jqGridPager"></div>
	
	<script type="text/javascript">
	window.onload=function(){
		
	}
	    var path = "${ctx}";
		$(document).ready(function()
		{
	 		
			$("#fileOrg").focus();
			$("#fileForm").validate({
				debug:true,
				rules: {
					
				},
				messages: {
					
				},
				submitHandler:function(form){
					$('#attPath').val($('ul.nav li.active a span').text()+"\\"); //设置将当前的文件类型，供后台创建文件目录用
					if(checkFileName('file')||$('#id').val()!=''){
						loading("文件上传中...");
						form.submit();
					}
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			
			var jqgridH = 410;
			$("#jqGrid").jqGrid(
			{ url : '${ctx}/dailySupervion/list.do?filter_EQS_tag=${tag}',
			  mtype : "GET",
			  datatype : "json",
			  page : 1,
			  viewrecords: true,
			  colModel:[
						{ label : "操作", name : "id", 
							  width : 100,   align : 'center', sortable : false, search : false ,
							  classes:'ui-jqgrid-optClass',
							  formatter: function (cellValue, options, rowObject){
						      	/* return "<a href='${ctx}/dailySupervion/input.do?id=" + cellValue + "&top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}' class='underline'><i class='glyphicon glyphicon-edit'></i>修改</a>"+
						          "<a href='${ctx}/dailySupervion/delete.do?id="+ cellValue +"&top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}' onclick='return confirm(\"确认要删除该记录吗？\", this.href)' ><i class='icon icon-remove'></i>删除</a>"; */
								  return dailySupervionFormatterOpt(cellValue);
							  }
						},
			            {
							label: '文件名',
			                name:  'fileName',
			                frozen:true,
			                align: 'center',
			                formatter: function (cellValue, options, rowObject){
								return downAttachment(cellValue,rowObject);
			                },
			                width: 250
			            },
			            {
							label: '文件类型',
			                name: 'type',
			                frozen:true,
			                align: 'center',
			                width: 100
			            },
			            {
							label: '发文单位',
			                name: 'fileOrg',
			                frozen:true,
			                align: 'center',
			                width: 100
			            },
			            {
							label: '所属单位',
			                name: 'ownOrg',
			                frozen:true,
			                align: 'center',
			                width: 120
			            },
			            {
							label: '文件号',
			                name: 'fileNo',
			                frozen:true,
			                align: 'center',
			                width: 100
			            },
			            {
							label: '文件大小(KB)',
			                name: 'size',
			                frozen:true,
			                align: 'center',
			                width: 100
			            },
			            {
							label: '上传用户',
			                name: 'uploadPerson',
			                align: 'center',
			                width: 100
			            },
			            {
							label: '上传日期',
			                name: 'fileTime',
			                align: 'center',
			                width: 150
			            }],
			autowidth : true, height : jqgridH,scrollOffset:0, shrinkToFit : 400, rowNum : 10, viewrecords : true, rownumbers : true,
			jsonReader:{
    			root: "result",
    			page: "currentPage",
    			total: "totalPages",
    			records: "totalCount",
    			repeatitems: true,
    			cell: "cell",
    			id: "id",
    			userdata: "userdata",
    			subgrid: {root:"results", repeatitems: true, cell:"cell"}
    		},
    		prmNames: {
				page:"pageNo",
				rows:"pageSize",
				sort: "orderBy",
				order: "order",
				search:"_search",
				nd:"nd", id:"id",
				oper:"oper",
				editoper:"edit",
				addoper:"add",
				deloper:"del",
				subgridid:"id",
				npage: null,
				totalrows:"totalCounts"
			}, 
			rowList :[10,20,30], 
			pager : "#jqGridPager"
			});
			
			 $('#jqGrid').navGrid("#jqGridPager", {                
	                search: true, // show search button on the toolbar
	                searchtext:'搜索',
	                add: false,
	                edit: false,
	                del: false,
	                refresh: true,
	                refreshtext:'刷新'
	            },
	            {}, // edit options
	            {}, // add options
	            {}, // delete options
	            { multipleSearch: true,multipleGroup: true} // search options - define multiple search
	            );

			$("#jqGrid").jqGrid('setGroupHeaders',
			{ useColSpanStyle : true, // 没有表头的列是否与表头列位置的空单元格合并
				});
			
			$('#jqGrid').navButtonAdd('#jqGridPager', {
				buttonicon : "glyphicon-excel",
				title : "导出数据",
				caption : "导出",
				position : "last",
				onClickButton : function() {
					$("#jqGrid").jqGrid('excelExport',{title:'道路清单'});
				}
			});
			$('#jqGrid').navButtonAdd('#jqGridPager',
					{ buttonicon : "glyphicon-count", title : "分组统计图表", caption : "分组统计", position : "last", onClickButton : function()
					{
						$("#jqGrid").jqGrid('setColumnstotal');
					} });
			$("#searchmodfbox_jqGrid").css("width", "660px");
		});
		
		function downAttachment(cellValue,rowObject){
	 		return "<a href='"+appConfig.contPath+"/servlet/annex?id="+rowObject['id']+"'  target='_blank' title='cellValue' style='text-decoration:none' >"+cellValue+"</a>";
	 	};
	</script>
</body>
</html>